package main

import (
	"fmt"
	"reflect"
)

func reflectFn(x interface{}) {
	var t = reflect.ValueOf(x)
	var k = t.Kind()
	if k == reflect.Int {
		fmt.Println(t.Int())
	} else if k == reflect.String {
		fmt.Println(t.String())
	} else if k == reflect.Bool {
		fmt.Println(t.Bool())
	} else if k == reflect.Float64 {
		fmt.Println(t.Float())
	} else {
		fmt.Println("未匹配到类型")
	}
}

func main() {
	var a = 1
	var b = "hello"
	var c = true
	var d = 12.3
	reflectFn(a)
	reflectFn(b)
	reflectFn(c)
	reflectFn(d)
}
